<?
  include('../init.php');

  $product_set_id= $_GET["aid"];
  
  $sql = "DELETE FROM product_set WHERE product_set_id=$product_set_id";
  $db->execute($sql);
  if(file_exists('../../images/products/set/'.$product_set_id)){
    remove_dir('../../images/products/set/'.$product_set_id);
  }
  
  $rss = $db->query("SELECT product_id FROM products WHERE product_set_id=$product_set_id");
  while ($line = $db->fetchNextObject($rss)){
    $sql = 'DELETE FROM products WHERE product_id='.$line->product_id;
    $db->execute($sql);
    
    if(file_exists('../../images/products/'.$line->product_id)){
      remove_dir('../../images/products/'.$line->product_id);
    }
  }

  header("Location:index.php");
?>